package org.study;

import org.study.module.InstallBuilder;
import org.study.module.TestClusterPlan;
import org.study.module.common.ModuleCommon;
import org.study.module.hadoop.MapReduceConfigBuilder;
import org.study.module.ldap.LDAPConfigBuilder;
import org.study.shell.ShellBase;
import org.study.utils.FileUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 在mac上执行主方法
 */
public class MacMain {
    public static void main(String... args){
//        test();
        install();
//        te();
    }

    public static void te(){
        List<String> configs = new ArrayList<>();
        configs.add("测试行1");
        configs.add("测试行2");
        ModuleCommon.configAppend(configs,"");
        LDAPConfigBuilder builder = new LDAPConfigBuilder();
        builder.addConfigs(configs);
        builder.installServer();
        List<String> values =  builder.toList();
        for (String value: values
             ) {
            System.out.println(value);
        }

    }

    private static void install(){
        InstallBuilder ib = new InstallBuilder("/Users/fujianli/Desktop/Java/hadoop-install/shell");
        ib.install(TestClusterPlan.selectByModuleInfoList(),TestClusterPlan.selectByClusterInfo(),TestClusterPlan.selectByModuleMachineList());
    }

    private static void test(){
        MapReduceConfigBuilder mb = new MapReduceConfigBuilder();
        List<String> commands = new ArrayList<>();
        commands.add("ls -l");
        commands.addAll(ShellBase.command("执行成功！","执行失败"));
        FileUtils.write(commands,"/Users/fujianli/Desktop/Java/hadoop-install/shell","command_sh.sh");
    }
}
